package lab5;

import static java.lang.Math.pow;

/**
 * Created with IntelliJ IDEA.
 * User: Борис
 * Date: 30.11.13
 * Time: 13:39
 * To change this template use File | Settings | File Templates.
 */
public class LabSixRun {
    public static void main(String[] args){
        double[][] matrix = {
                {         0,-7.0/23,5.0/23,   2.0/23},
                {-181.0/631,      0,     0,247.0/631},
                {    9.0/31, 5.0/31,     0,  -8/31.0},
                {         0,   -0.1,   0.2,        0},
        };
        double[][] b = {
                {   26.0/23},
                {1937.0/631},
                {   58.0/31},
                {      -2.4}
        };

//        double[][] matrix = {
//                {   0,-1.0/3,1.0/3},
//                { 0.4,     0,  0.4},
//                {0.25,  -0.5,    0},
//
//        };
//        double[][] b = {
//                { -1.0/3},
//                {      1},
//                { 11.0/4},
//        };

        int degree = -4;
        double accuracy = pow(10,degree);
        LabSix labSix = new LabSix(matrix,b,accuracy);
        showMatrix(labSix.methodOfSimpleIteration());
        System.out.println("\nЧисло итераций: "+labSix.getCount());

    }

    static void showMatrix(double[][] matrix){
        int strings = matrix.length;
        int columns = matrix[0].length;
        for(int i = 0; i<strings; i++){
            int index = i+1;
            System.out.println();
            for(int j = 0; j<columns; j++)
                System.out.print("X"+index+" = "+matrix[i][j]+"  ");
        }
    }
}

